local MainApp_ItemRenderer = class("MainApp_ItemRenderer")

function MainApp_ItemRenderer:ctor()

	-- MainApp_ItemRenderer.super.ctor(self) -- 调用父类构造函数

	local asset = ResManager.Asset.New("MainAppRaw/MotionBar.png",ResManager.AssetType.Sprite)
	resMgr:LoadAsset(asset,handler(self,self.onLoaded))
end

function MainApp_ItemRenderer:onLoaded(asset)
	self.go = GameObject.New('new go')
	local render = self.go:AddComponent(typeof(UnityEngine.SpriteRenderer))
	render.sprite = asset.sprite

	local v = Vector3.New()
	v.x = Util.Random(-3,3)
	v.y = Util.Random(-3,3)
	v.z = Util.Random(-3,3)
	self.go.transform.localPosition = v

	self._coDelay = coroutine.start(handler(self, self.delay))
end

function MainApp_ItemRenderer:delay()
	while true do
		coroutine.wait(Util.Random(1,5)) 
		self:dispose()
	end
end



function MainApp_ItemRenderer:dispose()
	if self.go ~= nil then
		destroy(self.go)

		luaMgr:LuaGC()
	end
end

return MainApp_ItemRenderer